package com.zhu.util;

import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.PrintWriter;

/**
 * Created by DELL on 2016/1/5.
 */
public class RespUtil {

    private static final Logger logger = LoggerFactory.getLogger(RespUtil.class);

    public static void jsonObject(HttpServletResponse resp, String msg, boolean result){
        JSONObject obj = new JSONObject();

        try{
            resp.setContentType("text/json");
            obj.put("msg", msg);
            obj.put("result", result);

            PrintWriter out = resp.getWriter();
            out.write(obj.toString());
            out.close();
        }catch(Exception e){
            logger.error(e.getMessage(), e);
        }
    }

}
